package com.rizzo.android.domain;

import com.j256.ormlite.dao.ForeignCollection;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.field.ForeignCollectionField;
import com.j256.ormlite.table.DatabaseTable;

import java.io.Serializable;

@DatabaseTable(tableName = Trend.TABLE_NAME)
public class Trend implements Serializable {

	public static final String TABLE_NAME = "trend";
	public static final String ID_FIELD = "_id";
	public static final String APPLICATION_FIELD = "application";
	public static final String INSTANCE_NAME_FIELD = "instance_name";
	public static final String INSTANCE_INDEX_FIELD = "instance_index";
	public static final String METHOD_FIELD = "method";
	public static final String APPLICATION_INDEX = "application_idx";
	public static final String METHOD_INDEX = "application_idx";
	public static final String[] AVAILABLE_FIELDS = {ID_FIELD, METHOD_FIELD, APPLICATION_FIELD, INSTANCE_NAME_FIELD, INSTANCE_INDEX_FIELD};

	@DatabaseField(id = true, columnName = ID_FIELD, generatedId = true)
	private long id;

	@DatabaseField(canBeNull = false, columnName = APPLICATION_FIELD, index = true, indexName = APPLICATION_INDEX)
	private String application;

	@DatabaseField(canBeNull = false, columnName = INSTANCE_NAME_FIELD)
	private String instanceName;

	@DatabaseField(canBeNull = false, columnName = INSTANCE_INDEX_FIELD)
	private String instanceIndex;

	@DatabaseField(canBeNull = false, columnName = METHOD_FIELD, index = true, indexName = METHOD_INDEX)
	private String method;

	@ForeignCollectionField(eager = false)
	private ForeignCollection<TrendData> trendData;

	public Trend() {
	}

	public Trend(String application, String instanceIndex, String instanceName, String method) {
		this.application = application;
		this.instanceIndex = instanceIndex;
		this.instanceName = instanceName;
		this.method = method;
	}

	public String getApplication() {
		return application;
	}

	public void setApplication(String application) {
		this.application = application;
	}

	public String getInstanceIndex() {
		return instanceIndex;
	}

	public void setInstanceIndex(String instanceIndex) {
		this.instanceIndex = instanceIndex;
	}

	public String getInstanceName() {
		return instanceName;
	}

	public void setInstanceName(String instanceName) {
		this.instanceName = instanceName;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getMethod() {
		return method;
	}

	public void setMethod(String method) {
		this.method = method;
	}

	public ForeignCollection<TrendData> getTrendData() {
		return trendData;
	}

	public void setTrendData(ForeignCollection<TrendData> trendData) {
		this.trendData = trendData;
	}
}
